<template>
  <el-popover
    class="avatar-container right-menu-item hover-effect"
    placement="bottom-end"
    width="315"
    offset="10"
    v-model="visible"
  >
    <div class="card__user__info">
      <ul>
        <li>姓名：{{ userInfo }}</li>
        <!-- <li>工号：{{ userInfo.sn }}</li>
        <li>部门：{{ userInfo.organizationList && userInfo.organizationList.map(item => item.name).length ? userInfo.organizationList.map(item => item.name).split(',') : '无部门' }}</li>
        <li>手机号：{{ userInfo.phoneNum }}</li>
        <li>邮箱：{{ userInfo.email }}</li> -->
      </ul>
      <div class="btn-bottom">
        <!-- <el-button type="text" @click="changePass">修改密码</el-button> -->
        <el-button type="text" @click="logout">退出登录</el-button>
      </div>
    </div>
    <div class="head__btn" slot="reference">
      <img src="~@/assets/images/user.png" alt>
      <span>{{ userInfo }}</span>
    </div>
  </el-popover>
</template>
<script>
import { mapGetters } from 'vuex'
export default {
  data() {
    return {
      visible: false
    };
  },
  methods: {
    changePass() {
      this.visible = false;
		},
		logout() {
      window.location.replace('./api/logout')
    }
	},
	computed: {
		...mapGetters(['userInfo'])
	},
	created() {
		//this.$store.dispatch('user/fetchUserInfo')
	}
};
</script>

<style lang="scss">
.avatar-container {
  padding: 0;
}
</style>
<style lang="scss" scoped>
.avatar-container {
  margin-right: 30px;
  .head__btn {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 50px;
    height: 50px;
    color: #ffffff;
    img {
      width: 50px;
      height: 50px;
    }
  }

  .avatar-wrapper {
    height: 100%;
    position: relative;
    display: flex;
    align-items: center;
    .user-avatar {
      cursor: pointer;
      width: 45px;
      height: 45px;
      border-radius: 10px;
    }

    .el-icon-caret-bottom {
      cursor: pointer;
      position: absolute;
      right: -20px;
      top: 25px;
      font-size: 12px;
    }
  }
}
.user__info {
  .head__btn {
    display: flex;
    align-items: center;
    cursor: pointer;
  }
  span {
    padding-left: 8px;
    font-size: 16px;
    color: #000;
  }
}
.card__user__info {
  ul {
    padding-bottom: 15px;
    li {
      padding-bottom: 10px;
    }
  }
  .btn-bottom {
    border-top: 1px solid #e7e7e7;
    display: flex;
    justify-content: flex-end;
  }
}
</style>

